package com.gewu.pm.ui.activity.work;

import android.content.Context;
import android.content.Intent;
import android.view.View;

import androidx.recyclerview.widget.RecyclerView;

import com.gewu.pm.app.AppAdapter;
import com.gewu.pm.bean.ManagementBean;
import com.gewu.pm.ui.activity.base.BaseManagementActivity;
import com.gewu.pm.ui.activity.filter.FilterPromotionVisitActivity;
import com.gewu.pm.ui.adapter.customer.VisitRecordAdapter;

/**
 * 拜访记录
 */
public final class VisitRecordActivity extends BaseManagementActivity<ManagementBean> {

    public static void start(Context context) {
        Intent intent = new Intent(context, VisitRecordActivity.class);
        context.startActivity(intent);
    }

    @Override
    protected String getPageTitle() {
        return "拜访记录";
    }

    @Override
    protected String getSearchHint() {
        return "输入终端名称/编码/地址";
    }

    @Override
    protected boolean showRecordCount() {
        return true;  // 显示"共X条记录"
    }

    @Override
    protected AppAdapter<ManagementBean> createAdapter() {
        return new VisitRecordAdapter(getContext());
    }

    @Override
    protected void loadData() {
        mDataList.clear();
        mDataList.add(new ManagementBean("终端名称展示在这里"));
        mDataList.add(new ManagementBean("线索名称展示在这里"));

        // 保存原始数据用于搜索
        setOriginalData(mDataList);

        mAdapter.setData(mDataList);
        updateRecordCount();  // 更新"共2条记录"
        updateEmptyView();
    }

    @Override
    protected String getSearchText(ManagementBean item) {
        // 搜索终端名称（item 左上角的文字）
        return item.getName();
    }

    @Override
    public void onItemClick(RecyclerView recyclerView, View itemView, int position) {
        ManagementBean item = mAdapter.getItem(position);
        // TODO: 跳转到拜访记录详情
        VisitCustomerActivity.start(getActivity(), "5");//固定状态  因为记录里面肯定都是已完成的
    }

    @Override
    public void onRightClick(View view) {
        super.onRightClick(view);
        FilterPromotionVisitActivity.start(this);
    }
}
